home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / uucp-104.lha / uucp-1.04 / uucp.h < prev    next >
C/C++ Source or Header  |  1993-02-13  |  11KB  |  368 lines

  1. /* uucp.h
  2.    Header file for the UUCP package.
  3.  
  4.    Copyright (C) 1991, 1992 Ian Lance Taylor
  5.  
  6.    This file is part of the Taylor UUCP package.
  7.  
  8.    This program is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU General Public License as
  10.    published by the Free Software Foundation; either version 2 of the
  11.    License, or (at your option) any later version.
  12.  
  13.    This program is distributed in the hope that it will be useful, but
  14.    WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with this program; if not, write to the Free Software
  20.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.    The author of the program may be contacted at ian@airs.com or
  23.    c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
  24.    */
  25.  
  26. /* Get the system configuration parameters.  */
  27. #include "conf.h"
  28. #include "policy.h"
  29.  
  30. /* Get a definition for ANSI_C if we weren't given one.  */
  31. #ifndef ANSI_C
  32. #ifdef __STDC__
  33. #define ANSI_C 1
  34. #else /* ! defined (__STDC__) */
  35. #define ANSI_C 0
  36. #endif /* ! defined (__STDC__) */
  37. #endif /* ! defined (ANSI_C) */
  38.  
  39. /* Pass this definition into uuconf.h.  */
  40. #define UUCONF_ANSI_C ANSI_C
  41.  
  42. /* We always include some standard header files.  We need <signal.h>
  43.    to define sig_atomic_t.  */
  44. #if HAVE_STDDEF_H
  45. #include <stddef.h>
  46. #endif
  47. #include <stdio.h>
  48. #include <signal.h>
  49.  
  50. /* On some systems we need <sys/types.h> to get sig_atomic_t or
  51.    size_t or time_t.  */
  52. #if ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && HAVE_SIG_ATOMIC_T_IN_TYPES_H
  53. #define USE_TYPES_H 1
  54. #else
  55. #if ! HAVE_SIZE_T_IN_STDDEF_H && HAVE_SIZE_T_IN_TYPES_H
  56. #define USE_TYPES_H 1
  57. #else
  58. #if ! HAVE_TIME_T_IN_TIME_H && HAVE_TIME_T_IN_TYPES_H
  59. #define USE_TYPES_H 1
  60. #endif
  61. #endif
  62. #endif
  63.  
  64. #ifndef USE_TYPES_H
  65. #define USE_TYPES_H 0
  66. #endif
  67.  
  68. #if USE_TYPES_H
  69. #include <sys/types.h>
  70. #endif
  71.  
  72. /* Make sure we have sig_atomic_t.  */
  73. #if ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && ! HAVE_SIG_ATOMIC_T_IN_TYPES_H
  74. #ifndef SIG_ATOMIC_T
  75. /* There is no portable definition for sig_atomic_t.  */
  76. #define SIG_ATOMIC_T char
  77. #endif /* ! defined (SIG_ATOMIC_T) */
  78. typedef SIG_ATOMIC_T sig_atomic_t;
  79. #endif /* ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && ! HAVE_SIG_ATOMIC_T_IN_TYPES_H */
  80.  
  81. /* Make sure we have size_t.  We use int as the default because the
  82.    main use of this type is to provide an argument to malloc and
  83.    realloc.  On a system which does not define size_t, int is
  84.    certainly the correct type to use.  */
  85. #if ! HAVE_SIZE_T_IN_STDDEF_H && ! HAVE_SIZE_T_IN_TYPES_H
  86. #ifndef SIZE_T
  87. #define SIZE_T unsigned
  88. #endif /* ! defined (SIZE_T) */
  89. typedef SIZE_T size_t;
  90. #endif /* ! HAVE_SIZE_T_IN_STDDEF_H && ! HAVE_SIZE_T_IN_TYPES_H */
  91.  
  92. /* Make sure we have time_t.  We use long as the default.  We don't
  93.    bother to let conf.h override this, since on a system which doesn't
  94.    define time_t long must be correct.  */
  95. #if ! HAVE_TIME_T_IN_TIME_H && ! HAVE_TIME_T_IN_TYPES_H
  96. typedef long time_t;
  97. #endif
  98.  
  99. /* Set up some definitions for both ANSI C and Classic C.
  100.  
  101.    P() -- for function prototypes (e.g. extern int foo P((int)) ).
  102.    pointer -- for a generic pointer (i.e. void *).
  103.    constpointer -- for a generic pointer to constant data.
  104.    BUCHAR -- to convert a character to unsigned.  */
  105. #if ANSI_C
  106. #if ! HAVE_VOID || ! HAVE_UNSIGNED_CHAR
  107.  #error ANSI C compiler without void or unsigned char
  108. #endif
  109. #define P(x) x
  110. typedef void *pointer;
  111. typedef const void *constpointer;
  112. #define BUCHAR(b) ((unsigned char) (b))
  113. #else /* ! ANSI_C */
  114. /* Handle uses of const, volatile and void in Classic C.  */
  115. #define const
  116. #define volatile
  117. #if ! HAVE_VOID
  118. #define void int
  119. #endif
  120. #define P(x) ()
  121. typedef char *pointer;
  122. typedef const char *constpointer;
  123. #if HAVE_UNSIGNED_CHAR
  124. #define BUCHAR(b) ((unsigned char) (b))
  125. #else /* ! HAVE_UNSIGNED_CHAR */
  126. /* This should work on most systems, but not necessarily all.  */
  127. #define BUCHAR(b) ((b) & 0xff)
  128. #endif /* ! HAVE_UNSIGNED_CHAR */
  129. #endif /* ! ANSI_C */
  130.  
  131. /* Make sure we have a definition for offsetof.  */
  132. #ifndef offsetof
  133. #define offsetof(type, field) \
  134.   ((size_t) ((char *) &(((type *) 0)->field) - (char *) (type *) 0))
  135. #endif
  136.  
  137. /* Only use inline with gcc.  */
  138. #ifndef __GNUC__
  139. #define __inline__
  140. #endif
  141.  
  142. /* Get the string functions, which are used throughout the code.  */
  143. #if HAVE_MEMORY_H
  144. #include <memory.h>
  145. #else
  146. /* We really need a definition for memchr, and this should not
  147.    conflict with anything in <string.h>.  I hope.  */
  148. extern pointer memchr ();
  149. #endif
  150.  
  151. #if HAVE_STRING_H
  152. #include <string.h>
  153. #else /* ! HAVE_STRING_H */
  154. #if HAVE_STRINGS_H
  155. #include <strings.h>
  156. #else /* ! HAVE_STRINGS_H */
  157. extern char *strcpy (), *strncpy (), *strchr (), *strrchr (), *strtok ();
  158. extern char *strcat (), *strerror (), *strstr ();
  159. extern size_t strlen (), strspn (), strcspn ();
  160. #if ! HAVE_MEMORY_H
  161. extern pointer memcpy (), memchr ();
  162. #endif /* ! HAVE_MEMORY_H */
  163. #endif /* ! HAVE_STRINGS_H */
  164. #endif /* ! HAVE_STRING_H */
  165.  
  166. /* Get what we need from <stdlib.h>.  */
  167. #if HAVE_STDLIB_H
  168. #include <stdlib.h>
  169. #else /* ! HAVE_STDLIB_H */
  170. extern pointer malloc (), realloc (), bsearch ();
  171. extern long strtol ();
  172. extern char *getenv ();
  173. #endif /* ! HAVE_STDLIB_H */
  174.  
  175. /* NeXT uses <libc.h> to declare a bunch of functions.  */
  176. #if HAVE_LIBC_H
  177. #include <libc.h>
  178. #endif
  179.  
  180. /* Make sure we have the EXIT_ macros.  */
  181. #ifndef EXIT_SUCCESS
  182. #define EXIT_SUCCESS (0)
  183. #endif
  184. #ifndef EXIT_FAILURE
  185. #define EXIT_FAILURE (1)
  186. #endif
  187.  
  188. /* If we need to declare errno, do so.  I don't want to always do
  189.    this, because some system might theoretically have a different
  190.    declaration for errno.  On a POSIX system this is sure to work.  */
  191. #if ! HAVE_ERRNO_DECLARATION
  192. extern int errno;
  193. #endif
  194.  
  195. /* If the system has the socket call, guess that we can compile the
  196.    TCP code.  */
  197. #define HAVE_TCP HAVE_SOCKET
  198.  
  199. /* If the system has the t_open call, guess that we can compile the
  200.    TLI code.  */
  201. #define HAVE_TLI HAVE_T_OPEN
  202.  
  203. /* The boolean type holds boolean values.  */
  204. typedef int boolean;
  205. #undef TRUE
  206. #undef FALSE
  207. #define TRUE (1)
  208. #define FALSE (0)
  209.  
  210. /* The openfile_t type holds an open file.  This depends on whether we
  211.    are using stdio or not.  */
  212. #if USE_STDIO
  213.  
  214. typedef FILE *openfile_t;
  215. #define EFILECLOSED ((FILE *) NULL)
  216. #define ffileisopen(e) ((e) != NULL)
  217. #define ffileeof(e) feof (e)
  218. #define cfileread(e, z, c) fread ((z), 1, (c), (e))
  219. #define ffilereaderror(e, c) ferror (e)
  220. #define cfilewrite(e, z, c) fwrite ((z), 1, (c), (e))
  221. #ifdef SEEK_SET
  222. #define ffileseek(e, i) (fseek ((e), (long) (i), SEEK_SET) == 0)
  223. #define ffilerewind(e) (fseek ((e), (long) 0, SEEK_SET) == 0)
  224. #else
  225. #define ffileseek(e, i) (fseek ((e), (long) (i), 0) == 0)
  226. #define ffilerewind(e) (fseek ((e), (long) 0, 0) == 0)
  227. #endif
  228. #define ffileclose(e) (fclose (e) == 0)
  229.  
  230. #else /* ! USE_STDIO */
  231.  
  232. #if HAVE_UNISTD_H
  233. #include <unistd.h>
  234. #endif
  235.  
  236. typedef int openfile_t;
  237. #define EFILECLOSED (-1)
  238. #define ffileisopen(e) ((e) >= 0)
  239. #define ffileeof(e) (FALSE)
  240. #define cfileread(e, z, c) read ((e), (z), (c))
  241. #define ffilereaderror(e, c) ((c) < 0)
  242. #define cfilewrite(e, z, c) write ((e), (z), (c))
  243. #ifdef SEEK_SET
  244. #define ffileseek(e, i) (lseek ((e), (long) i, SEEK_SET) >= 0)
  245. #define ffilerewind(e) (lseek ((e), (long) 0, SEEK_SET) >= 0)
  246. #else
  247. #define ffileseek(e, i) (lseek ((e), (long) i, 0) >= 0)
  248. #define ffilerewind(e) (lseek ((e), (long) 0, 0) >= 0)
  249. #endif
  250. #define ffileclose(e) (close (e) >= 0)
  251.  
  252. #endif /* ! USE_STDIO */
  253.  
  254. /* A prototype for main to avoid warnings from gcc 2.0
  255.    -Wmissing-prototype option.  */
  256. extern int main P((int argc, char **argv));
  257.  
  258. /* Some standard routines which we only define if they are not present
  259.    on the system we are compiling on.  */
  260.  
  261. #if ! HAVE_GETLINE
  262. /* Read a line from a file.  */
  263. extern int getline P((char **pz, size_t *pc, FILE *e));
  264. #endif
  265.  
  266. #if ! HAVE_REMOVE
  267. /* Erase a file.  */
  268. #undef remove
  269. extern int remove P((const char *zfile));
  270. #endif
  271.  
  272. #if ! HAVE_STRDUP
  273. /* Copy a string into memory.  */
  274. extern char *strdup P((const char *z));
  275. #endif
  276.  
  277. #if ! HAVE_STRSTR
  278. /* Look for one string within another.  */
  279. extern char *strstr P((const char *zouter, const char *zinner));
  280. #endif
  281.  
  282. #if ! HAVE_STRCASECMP
  283. #if HAVE_STRICMP
  284. #define strcasecmp stricmp
  285. #else /* ! HAVE_STRICMP */
  286. /* Rename strcasecmp to avoid ANSI C name space.  */
  287. #define strcasecmp xstrcasecmp
  288. extern int strcasecmp P((const char *z1, const char *z2));
  289. #endif /* ! HAVE_STRICMP */
  290. #endif /* ! HAVE_STRCASECMP */
  291.  
  292. #if ! HAVE_STRNCASECMP
  293. #if HAVE_STRNICMP
  294. #define strncasecmp strnicmp
  295. #else /* ! HAVE_STRNICMP */
  296. /* Rename strncasecmp to avoid ANSI C name space.  */
  297. #define strncasecmp xstrncasecmp
  298. extern int strncasecmp P((const char *z1, const char *z2, size_t clen));
  299. #endif /* ! HAVE_STRNICMP */
  300. #endif /* ! HAVE_STRNCASECMP */
  301.  
  302. #if ! HAVE_STRERROR
  303. /* Get a string corresponding to an error message.  */
  304. #undef strerror
  305. extern char *strerror P((int ierr));
  306. #endif
  307.  
  308. /* Get the appropriate definitions for memcmp, memcpy, memchr and
  309.    bzero.  */
  310. #if ! HAVE_MEMCMP
  311. #if HAVE_BCMP
  312. #define memcmp(p1, p2, c) bcmp ((p1), (p2), (c))
  313. #else /* ! HAVE_BCMP */
  314. extern int memcmp P((constpointer p1, constpointer p2, size_t c));
  315. #endif /* ! HAVE_BCMP */
  316. #endif /* ! HAVE_MEMCMP */
  317.  
  318. #if ! HAVE_MEMCPY
  319. #if HAVE_BCOPY
  320. #define memcpy(pto, pfrom, c) bcopy ((pfrom), (pto), (c))
  321. #else /* ! HAVE_BCOPY */
  322. extern pointer memcpy P((pointer pto, constpointer pfrom, size_t c));
  323. #endif /* ! HAVE_BCOPY */
  324. #endif /* ! HAVE_MEMCPY */
  325.  
  326. #if ! HAVE_MEMCHR
  327. extern pointer memchr P((constpointer p, int b, size_t c));
  328. #endif
  329.  
  330. #if ! HAVE_BZERO
  331. #if HAVE_MEMSET
  332. #define bzero(p, c) memset ((p), 0, (c))
  333. #else /* ! HAVE_MEMSET */
  334. extern void bzero P((pointer p, int c));
  335. #endif /* ! HAVE_MEMSET */
  336. #endif /* ! HAVE_BZERO */
  337.  
  338. /* Look up a character in a string.  */
  339. #if ! HAVE_STRCHR
  340. #if HAVE_INDEX
  341. #define strchr index
  342. extern char *index ();
  343. #else /* ! HAVE_INDEX */
  344. extern char *strchr P((const char *z, int b));
  345. #endif /* ! HAVE_INDEX */
  346. #endif /* ! HAVE_STRCHR */
  347.  
  348. #if ! HAVE_STRRCHR
  349. #if HAVE_RINDEX
  350. #define strrchr rindex
  351. extern char *rindex ();
  352. #else /* ! HAVE_RINDEX */
  353. extern char *strrchr P((const char *z, int b));
  354. #endif /* ! HAVE_RINDEX */
  355. #endif /* ! HAVE_STRRCHR */
  356.  
  357. /* Turn a string into a long integer.  */
  358. #if ! HAVE_STRTOL
  359. extern long strtol P((const char *, char **, int));
  360. #endif
  361.  
  362. /* Lookup a key in a sorted array.  */
  363. #if ! HAVE_BSEARCH
  364. extern pointer bsearch P((constpointer pkey, constpointer parray,
  365.               size_t celes, size_t cbytes,
  366.               int (*pficmp) P((constpointer, constpointer))));
  367. #endif
  368.